﻿/***************************
 * 数据访问层
 * 现场照片状况
 * Author：JXL
 ***************************/ 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IDAL;
using Model;
using System.Data;
using System.Data.SqlClient;
using HouseCommon;

namespace DAL
{
   public class PhotoDAL:BaseDAL, IPhotoDAL
    {

        protected override string tablename
        {
            get { return "Photo"; }
        }

        protected override Dictionary<string, bool> pkname
        {
            get
            {
                Dictionary<string, bool> id = new Dictionary<string, bool>();

                id.Add("photo_Id", true);
                return id;
            }
        }
       /// <summary>
       /// 插入
       /// </summary>
       /// <param name="list"></param>
       /// <returns></returns>
        public int insert(List<Photo> list)
        {
            string str = "";
            foreach (var item in list)
            {
                str += HouseCommon.Common.sqltostring<Photo>(item, tablename, pkname) + ";";
            }
            str = str.Substring(0, str.Length - 1);
            return DBhelper.NonQuery(str);

        }

        public  int updates(List<Photo> list,string where)
        {
            string str = "delete Photo where "+where+";";
            foreach (var item in list)
            {
                str += HouseCommon.Common.sqltostring<Photo>(item, tablename, pkname) + ";";
            }
            str = str.Substring(0, str.Length - 1);
            return DBhelper.NonQuery(str);
        }
       /// <summary>
       /// 展示
       /// </summary>
       /// <param name="where"></param>
       /// <returns></returns>
        public  List<Photo> getlist(string where) 
        {
            var sqlstr = Common.gettostring<Photo>(where, tablename);
            return DBhelper.DBHelper.GetList<Photo>(sqlstr);
        }
    }
}
